package com.example.demo;

import com.clearofchina.core.model.ErrorCode;

/**
 * @author gxing
 * @desc 消息平台错误码, 以71开头
 * @date 2021/8/4
 */
public enum MessageErrorEnum implements ErrorCode {

    SEND_FAIL(710001, "发送失败"),
    TOKEN_TYPE_ERROR(710002, "获取token类型错误"),
    REQUEST_PARAM_EMPTY_ERROR(710003, "请求参数为空错误"),
    SEND_MESSAGE_FAIL(710004, "消息发送失败"),
    MESSAGE_TYPE_FAIL(710005, "消息类型错误"),
    TEMPLATE_NOT_PERMIT(710006, "消息模板未授权"),
    CHANNEL_CONFIG_NOT_EXIST(710007, "消息渠道未配置"),
    SEND_MESSAGE_RESPONSE_NULL(710008, "消息发送失败,响应为空"),
    TEMPLATE_NOT_EXIST(710009, "模板不存在"),
    MESSAGE_OBJECT_PATIENT_EXCEL_URL_EMPTY(710010, "上传患者Excel Url为不能空"),
    MESSAGE_OBJECT_EMP_LIST_EMPTY(710011, "雇员列表不能为空"),
    SEND_TIME_EMPTY(710012, "发送时间不能为空"),
    IS_AUDIT_EMPTY(710013, "是否需要审核不能为空"),
    SEND_CHANNEL_EMPTY(710014, "发送渠道不能为空"),
    CUSTOM_SMS_PHONE_EMPTY(710015, "自定义短信,手机号为空"),
    MESSAGE_ALIPAY_AUTHCODE_FAIL(710016, "支付宝首页消息小程序授权码为空"),
    TEMPLATE_NOT_CONTENT(710017, "消息模板内容未配置"),
    MESSAGE_ALIPAY_BUYERID_FAIL(710018, "支付宝首页消息小程序用户id为空"),
    MESSAGE_ALIPAY_TOKEN_FAIL(710018, "支付宝首页消息小程序获取token失败"),
    MESSAGE_WX_NOT_SUBSCRIBE_ERROR(710019, "用户未关注公众号"),
    MESSAGE_WX_NO_OPENID(710020, "没有openid"),
    MESSAGE_WX_INVALID_OPENID(710021, "无效的openid,可能是其它公众号的openid"),
    MESSAGE_WX_SYSTEM_ERROR(710022, "微信返回系统错误"),
    MESSAGE_WX_INVALID_TEMPLATE_ID(710023, "微信消息模板id无效"),
    MESSAGE_WX_INVALID_ACCESS_TOKEN(710024, "access_token无效或不是最新"),
    MESSAGE_CHANNEL_ACCOUNT_EMPTY(710025,"机构的消息渠道账号为空,请在管理后台添加"),
    MESSAGE_CHANNEL_APPID_NO_ACCOUNT(710026,"指定的渠道appid未配置账号信息,请在管理后台添加"),
    MESSAGE_ORG_CHANNEL_NOT_EXIST(710027,"机构消息渠道不存在"),
    MESSAGE_SEND_INVALID_PATIENT(710028, "从请求体或者患者中心获取不到openid"),
    MESSAGE_WX_TEMPLATE_ID_BLANK(710029, "微信公众号模板ID长度错误或为空未配置"),
    ;


    private int code;

    private String message;

    private MessageErrorEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public ErrorCode parse(int code) {
        MessageErrorEnum[] values = MessageErrorEnum.values();
        for (int i = 0; i < values.length; i++) {
            MessageErrorEnum value = values[i];
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }
}
